package unit3.part5;

import java.util.Scanner;

/**
 * 自由落体
 */
public class FreeFall {
    public static void main(String[] args) {
        //接收用户输入的弹跳次数
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入弹跳次数：");
        int num = scanner.nextInt();
        scanner.close();

        int height = 10000; //球体高度，默认10000
        for (int i = 1; i <= num; i++) {//计算反弹
            height = height / 2;
            if (height == 0) {//判断球体是否已经落地
                System.out.println("第" + i + "次反弹后，球体落地");
                break;
            }
        }
        System.out.println(num + "次反弹后，当前球体的高度是：" + height);
    }
}
